<?php

declare(strict_types=1);

/**
 * 订单商品
 * @author chenshubo
 */
namespace App\Controller\Shop;

use App\Model\PssModel\OrderSupplier;
use Hyperf\HttpServer\Contract\RequestInterface;
use App\Model\PssModel\Accountlog;
use App\Model\PssModel\OrderRecharge;
use App\Service\OrderService\OrderQueryService\QueryUserOrderService;
class OrderController extends AbstractController
{
    /**
     * 用户订单列表数据导出接口
     */
    public function userOrderExport(RequestInterface $request)
    {
        $binfo = $request->getAttribute('param')['binfo'];
        $body  = $request->getAttribute('param')['body'];
        return QueryUserOrderService::instance()->userOrderExport($binfo,$body);
    }
    
    /**
     * 获取订单列表新版本接口
     */
    public function queryOrderSupplierList(RequestInterface $request)
    {
        $binfo = $request->getAttribute('param')['binfo'];
        $body  = $request->getAttribute('param')['body'];
        return QueryUserOrderService::instance()->queryUserOrderSupplierLists($binfo,$body);
    }
    
    /**
     * 获取订单列表旧版本接口
     */
    public function orderSupplierList(RequestInterface $request)
    {
        return OrderSupplier::instance()->orderSupplierList($request->getAttribute('param'));
    }
    
    /**
     * 订单详情
     */
    public function orderInfo(RequestInterface $request)
    {
        return OrderSupplier::instance()->orderInfo($request->getAttribute('param'));
    }
    
    /**
     * 订单预支付订单信息
     */
    public function orderPrePayInfo(RequestInterface $request)
    {
        return OrderSupplier::instance()->orderPrePayInfo($request->getAttribute('param'));
    }
    
    /**
     * 获取支付结果
     */
    public function getOrderPayResult(RequestInterface $request) 
    {
        return OrderSupplier::instance()->getOrderPayResult($request->getAttribute('param'));
    }
    
    /**
     * 订单取消订单
     */
    public function orderCancel(RequestInterface $request)
    {
        return OrderSupplier::instance()->orderCancel($request->getAttribute('param'));
    }
    
    /**
     * 订单申请售后
     */
    public function orderAfterSale(RequestInterface $request)
    {
        return OrderSupplier::instance()->orderAfterSale($request->getAttribute('param'));
    }
    
    /**
     * 商品下单详情页面
     */
    public function placeOrderDetail(RequestInterface $request) 
    {
        return OrderSupplier::instance()->placeOrderDetai($request->getAttribute('param'));
    }
    
    /**
     * 提交订单接口
     */
    public function placeOrder(RequestInterface $request) 
    {
        return OrderSupplier::instance()->placeOrder($request->getAttribute('param'));
    }
    
    /**
     * 订单支付接口
     */
    public function orderPay(RequestInterface $request) 
    {
        $param = $request->getAttribute('param');
        $param['body']['pay_type'] = PAY_TYPE_ORDER;//订单在线下单
        return OrderSupplier::instance()->orderPay($param);
    }
    
    /**
     * 在线充值接口
     */
    public function orderRecharge(RequestInterface $request)
    {
        $param = $request->getAttribute('param');
        $param['body']['order_sn'] = "CZ".date('YmdHis').substr(microtime(), 2,6);
        $param['body']['pay_type'] = PAY_TYPE_RECHARGE;//在线充值支付
        return OrderSupplier::instance()->orderPay($param);
    }
    
    /**
     * 在线订单日志
     */
    public function orderRechargePageList(RequestInterface $request)
    {
        return Accountlog::instance()->getUserAccoutLogList($request->getAttribute('param'));
    }

    /**
     * 通联获取支付结果
     */
    public function alinOrderPayResult(RequestInterface $request)
    {
        return OrderSupplier::instance()->alinOrderPayResult($request->getAttribute('param'));
    }
    
    /**
     * 通联在线充值结果
     */
    public function getAlinPayRechargeResult(RequestInterface $request)
    {
        return OrderRecharge::instance()->getAlinPayRechargeResult($request->getAttribute('param'));
    }
}
